<!--
 * @Author: wrh123 482597539@qq.com
 * @Date: 2024-01-16 10:46:46
 * @LastEditors: wrh123 482597539@qq.com
 * @LastEditTime: 2024-01-25 17:26:31
 * @FilePath: /vue-admin/src/views/Profit/components/addpayList.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="PendingBtn">
    <el-dialog title="缴费确认" :visible="dialogVisible" width="30%" :before-close="handleClose">
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px">
        <el-form-item prop="paymentResult " label="申请结果">
          <el-select v-model="ruleForm.paymentResult" size="mini">
            <el-option v-for="item in sponsorship" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="ruleForm.paymentResult === 3" prop="paymentDisposeRemark" label="备注">
          <el-input v-model="ruleForm.paymentDisposeRemark" size="mini" />
        </el-form-item>
        <el-form-item>
          <el-row type="flex" justify="end" style="margin-top: 10px;">
            <el-button size="mini" @click="handleClose">取 消</el-button>
            <el-button size="mini" type="primary" @click="btnOK">保存</el-button>
          </el-row>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { handlePayment } from '@/api/Profit'

export default {
  name: 'VueAdminAddpayList',
  props: {
    dialogVisible: {
      default: false,
      type: Boolean
    },
    dialogId: {
      default: null,
      type: Object
    }
  },
  data() {
    return {
      ruleForm: {
        paymentDisposeRemark: null,
        id: null,
        paymentResult: null
      },
      rules: {
        paymentDisposeRemark: [{ required: true, message: '备注不可以为空', trigger: 'blur' }],
        paymentResult: [{ required: true, message: '处理结果不可以为空', trigger: 'change' }]
      },
      sponsorship: [
        { id: 2, name: '已缴费' },
        { id: 3, name: '已驳回' }
      ]
    }
  },
  watch: {
    dialogId(old, Val) {
      this.ruleForm.id = old.id
    }
  },

  mounted() {
  },

  methods: {
    // 取消
    handleClose() {
      this.$refs.ruleForm.resetFields()
      this.$emit('update:dialogVisible', false)
    },
    // 确定
    async btnOK() {
      await this.$refs.ruleForm.validate()
      await handlePayment(this.ruleForm)
      this.$message.success('操作成功')
      this.$emit('refresh')
      this.handleClose()
    }
  }
}
</script>

<style lang="scss" scoped></style>
